package nowcoder.nc68;

import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 
     * @param number int整型 
     * @return int整型
     */
    public int jumpFloor (int number) {
        //递归
//        if (number==1) return 1;
//        else if (number==2) return 2;
//        return jumpFloor(number-1)+jumpFloor(number-2);

        //动态规划
        //j1=1,
        //j2=2,
        //j3=j1+j2
        //j4=j3+j2
        //ji=j[i-1]+j[i-2]
        if (number<3) return number;
        int result=0;
        int j1=1,j2=2;
        for (int i=3;i<=number;i++){
            result=j1+j2;
            j1=j2;
            j2=result;
        }
        return result;
    }

    public static void main(String[] args) {
        System.out.println(new Solution().jumpFloor(9));
    }
}